import JSEncrypt from 'jsencrypt';
import config from "@/js/util/config.js";

/**
 * JSEncrypt: 加密
 * @param str
 */
 export function encrypt(str) {
    let pubKey = config.data.key;
    let encryptStr = new JSEncrypt();
    encryptStr.setPublicKey(pubKey);
    let data = encryptStr.encrypt(str.toString());
    return data;
};

/**
 * JSEncrypt: 解密
 * @param msg
 */
export function decrypt(msg) {
    let pubKey = config.data.key;
    let decrypt = new JSEncrypt();
    decrypt.setPrivateKey(pubKey);
    var decryptMsg = decrypt.decrypt(msg.toString());
    return decryptMsg;
};